// 从vue-router这个依赖库中导入createRouter()函数, createWebHistory()函数
import { createRouter, createWebHistory } from 'vue-router'

// 定义一个变量
const router = createRouter({
    // 路由历史
    history: createWebHistory(),
    // 配置路由, 是一个数组, 可以配置多个路由
    routes: [
        {
            // 路由路径
            path: '/',
            // 路由路径所对应的页面
            component: () => import('../view/LoginView.vue')
        },
        {
            path: '/dashboard',
            component: () => import('../view/DashboardView.vue'),
            // 子路由
            children: [
              {
                // 子路由路径不能以/开头
                path: '',
                component: () => import('../view/StatisticView.vue')
              },
              {
                // 子路由路径不能以/开头
                path: 'user',
                component: () => import('../view/UserView.vue')
              },
              {
                // id是动态变量 -> 动态路由
                path: 'user/:id',
                component: () => import('../view/UserDetailView.vue')
              },
              {
                path: 'activity',
                component: () => import('../view/ActivityView.vue')
              },
              {
                path: 'activity/add',
                component: () => import('../view/ActivityRecordView.vue')
              },
              {
                path: 'activity/edit/:id',
                component: () => import('../view/ActivityRecordView.vue')
              },
              {
                path: 'activity/:id',
                component: () => import('../view/ActivityDetailView.vue')
              },
              {
                path: 'clue',
                component: () => import('../view/ClueView.vue')
              },
              {
                path: 'clue/add',
                component: () => import('../view/ClueRecordView.vue')
              },
              {
                path: 'clue/edit/:id',
                component: () => import('../view/ClueRecordView.vue')
              },
              {
                path: 'clue/detail/:id',
                component: () => import('../view/ClueDetailView.vue')
              },
              {
                path: 'customer',
                component: () => import('../view/CustomerView.vue')
              }
            ]
        }
    ]
})

// 导出创建的路由对象
export default router
